import api from '../../utils/api/api'
import tool from "../../utils/publics/tool"

Page({
  data: {
    banner: [], // 轮播图
    exhibition: [], // 会展列表
    getjkl_lst:{},    // 金钠卡
    jkl_detail:{},    // 金钠卡详情
  },
  onLoad(options) {
    console.log(options, "首页");
    console.log("缓存渠道id",tool.storage("scene"));
    if(options.scene){
      tool.storage("scene", options.scene);
    }
    this.get_banner()
    this.getData();
    this.getjkl_lst();
  },
  onShow(){
    tool.storage("id", '');
    tool.storage("pink_id", '');
    if(this.data.getjkl_lst.id){
    this.jkl_detail();
    }
    
  },
  // 获取轮播图
  get_banner() {
    api.get_banner().then(res => {
      console.log(res);
      if (res.code == 1) {
        this.setData({
          banner: res.data
        })
      }
    })
  },
  // 获取数据
  getData() {
    api.ex_list().then(res => {
      let {
        code,
        data,
        msg
      } = res;
      if (code == 1) {
        this.setData({
          exhibition: data
        })
      }
    })
  },
  // 获取金钠赛数据
  getjkl_lst(){
    api.jkl_lst().then(res=>{
      let {
        code,
        data,
        msg
      } = res;
      if (code == 1) {
        this.setData({
          getjkl_lst: data
        });
       this.jkl_detail();
      }
    })
  },
  // 获取金钠赛详情
  jkl_detail(){
    api.jkl_detailt({id:this.data.getjkl_lst.id}).then(res=>{
      let {
        code,
        data,
        msg
      } = res;
      if (code == 1) {
        this.setData({
          jkl_detail: data
        })
      }
    })
  },
  // 授权
  getUserInfoCallback(e){
    if (e.detail.status) {
      if(this.data.jkl_detail.join_detail.pay_status==1){   	//支付状态 0待支付 1已支付 -1已取消   
        tool.jump_nav(`/pages/pages-list/success2/success2?id=${this.data.getjkl_lst.id}`)
      }else{
        tool.jump_nav(`/pages/pages-list/huizhan-details2/huizhan-details2?id=${this.data.getjkl_lst.id}`)
      }
      // tool.jump_nav(`/pages/pages-list/huizhan-details2/huizhan-details2?id=${this.data.getjkl_lst.id}`)
    }
  },
  // 跳转
  skip(e) {
    let id = e.detail.id;
    let type = e.currentTarget.dataset.type;
    if(type==2){
      // if(this.data.jkl_detail.join_detail.pay_status==1){   	//支付状态 0待支付 1已支付 -1已取消   
      //   tool.jump_nav(`/pages/pages-list/success2/success2?id=${this.data.getjkl_lst.id}`)
      // }else{
        tool.jump_nav(`/pages/pages-list/huizhan-details2/huizhan-details2?id=${this.data.getjkl_lst.id}`)
      // }
    }else{
      tool.jump_nav(`/pages/pages-list/huizhan-details/huizhan-details?id=${id}`)
    }
  },


})